<?php
/**
 * Grid to display company contacts 
 * 
 * 
 */

use Fox\Generator;
$grid = new Fox\Grid('contacts');
$grid->fieldcat(array('first_name','last_name','jobtitle','email','phone1','phone2',array('contact_vip','importance')));
$grid->fieldcat()
	->field('importance')
		->align('center')
		->setGenerator(Generator::useFunction(function($data){
			$expid = $data['expid'];
			$rid = $data['ressource_id'];
			
			if($data['importance'] > 0) {
				$action = '{\'target\':\'?mod=company&act=contacts&sac=tag&expid='.$expid.'&rid='.$rid.'\',\'message\':1,\'toggle\':1}';
				$link = '<a href="?" class="clickable icons mark-as-vip active action '.$action.'"><i class="icon">&nbsp;</i></a>';
			} else {
				$action = '{\'target\':\'?mod=company&act=contacts&sac=tag&expid='.$expid.'&rid='.$rid.'\',\'message\':1,\'toggle\':1}';
				$link = '<a href="?" class="clickable icons mark-as-vip action '.$action.'"><i class="icon">&nbsp;</i></a>';
			}
			return $link;
		}));
return $grid;